package com.tongji.showroom.service
{ 
    import com.tongji.showroom.events.GetTypesEvent;
    import com.tongji.showroom.vo.ObjectTranslator;
    import com.tongji.showroom.vo.Type;
    
    import flash.system.Security;
    
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.soap.WebService;
    
    import org.robotlegs.mvcs.Actor;
	
	
	/**
	 * 
	 * @author jiarong
	 * 
	 */
	public class TypeService extends Actor
	{
		private var webService:WebService;
		
		public function TypeService()
		{
			super();
			webService = new WebService;
			webService.wsdl = "http://share.rryjw.com/VRService.asmx?wsdl";
			webService.useProxy = false;
			webService.loadWSDL();
			Security.loadPolicyFile("http://img.rryjw.com/crossdomain.xml");
		}
		
		/**
		 *获取场景场地类型
		 * 
		 */		
		public function getPlaces():void
		{
			webService.GetPlace();
			webService.GetPlace.addEventListener(ResultEvent.RESULT, getPlaceResult);
			webService.Getpalce.addEventListener(FaultEvent.FAULT, handleFault);
		}
		
		/**
		 *获取场景风格类型 
		 * 
		 */		
		public function getStyles():void
		{
			webService.GetStyle();
			webService.GetStyle.addEventListener(ResultEvent.RESULT,getStyleResult);
			webService.GetStyle.addEventListener(FaultEvent.FAULT,handleFault);
		}
		
		private function getPlaceResult(event:ResultEvent):void
		{
			dispatch(new GetTypesEvent(GetTypesEvent.UPADATE_PLACES, event.result as String));
		}
		
		private function getStyleResult(event:ResultEvent):void
		{
			dispatch(new GetTypesEvent(GetTypesEvent.UPDATE_STYLES, event.result as String));
		}
		
		private function handleFault(event:FaultEvent):void
		{
			Alert.show("失败" + event.fault.toString());
		}
	}
}